package com.sxsihe.heartmate.view;

import android.content.Context;
import android.os.Handler;
import android.os.Message;
import com.sxsihe.heartmate.R;

/**
 * Created by mgxc2 on 15/12/2.
 */
public class CustomWaittingDialog {

    public CustomWaittingDialog(Context context, int resId) {
        dialog = new CustomProgressDialog(context, "正在加载中", resId);
    }

    static CustomProgressDialog dialog;

    Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case 0: {
                    dialog.show();
                    break;
                }
                case 1: {
                    dialog.dismiss();
                    break;
                }
                default:
                    break;
            }
        }
    };

    public void showWaitting() {
        Message msg = handler.obtainMessage();
        msg.what = 0;
        handler.sendMessage(msg);
    }

    public void hideWaitting() {
        Message msg = handler.obtainMessage();
        msg.what = 1;
        handler.sendMessage(msg);
    }
}
